﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DAO;
using DVO;

public partial class Register : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //if (Page.User.Identity.Name=="")
        //{
        //    Response.Redirect("Login.aspx");
        //}
        if (IsPostBack == false)
        {
            LoadRoles();
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        BLL_Working ObjBLL = new BLL_Working();
        string username=txtUsername.Text.Trim();
        string pass=Common.GenerateHashDigestMD5(txtpass.Text.Trim(),Common.HashMethod.MD5);
        int RolesId = Convert.ToInt32(DropDownList1.SelectedValue);
        if (ObjBLL.ins_Member_Insert(username, pass, RolesId) > 0)
        {
            lbmessage.Text = "Tạo tài khoản thành công";
        }
    }

    private void LoadRoles()
    {
        BLL_Member ObjBLL = new BLL_Member();
        List<ins_RolesDetail_SelectAllResult> Objlist = new List<ins_RolesDetail_SelectAllResult>();
        try
        {
            Objlist = ObjBLL.Roels_SelectALL().ToList();
            DropDownList1.DataSource = Objlist;
            DropDownList1.DataTextField = "RolesName";
            DropDownList1.DataValueField = "Id";
            DropDownList1.DataBind();
        }
        catch (Exception ex)
        {
            Common.WriteLog(ex.Message, ex.StackTrace);
        }


    }
}